< previous page page_519 next page >

Page 519
First, the CreateLocalFile function gets the filename from the Dbpath= INI entry and uses Visual Basic's CreateDatabase function to create the new (and empty MDB) file. Next, the program uses a For loop to read through each table in the [Tables] section, repeatedly calling the CreateTable procedure. The CreateTable procedure, in turn, loops through the fields in the [tablename] section of the INI file, creating fields in the new table.
After a table is created, the TransferTable procedure takes care of transferring the data from an SQL Server table to one of the new tables. The procedure first creates a recordset from the SQL Server table and then loops through each record in the recordset, transferring the value for each field to the new table. During this process, users see a progress bar, as shown in Figure 23.4, to let them know something is happening.
0519-01.jpg
Figure 23.4
The SQL data export program
displays a progress bar while in action.
Using the Windows API to Create Transparent Images
One of the most complex features in the Win32 API is the Graphics Device Interface (GDI) APIs. Because these APIs are very complicated, tedious, and GPF prone, Microsoft played it safe and excluded most of them from VB. Although leaving out the APIs shelters you from the complexity and makes your programs more robust, it severely limits your ability to do the ''cool" things that many users expect. VB4 helped to relieve this problem to some extent by providing new features such as the PaintPicture function and the ImageList control, but it still fell short. This means that sometime in the near future you are going to find yourself calling the GDI APIs from your application. To demonstrate some of the more common GDI APIs, you'll write a cool function called TransparentPaint in this section.
note.gif The version of the TransparentPaint routine you see in this chapter is a Win32 version of the TransparentBlt code (written by Mike Bond) that originally appeared in the Microsoft KnowledgeBase KB article number Q94961. This version contains many modifications to the code and includes a wealth of new comments. square.gif

TransparentPaint, shown in Listing 23.4, is designed to treat a bitmap like an icon when you paint it on a surface. You can designate a part of the icons to be transparent, but you cannot do the same with bitmaps. TransparentPaint overcomes this limitation by allowing you to make all of a single color on a bitmap transparent. To accomplish this difficult feat, you need to create a series of temporary bitmaps and do some painting in memory only. Although this abstract concept can be complicated, the comments in TransparentPaint help explain what is happening at each step.

 
< previous page page_519 next page >